#include "fig_sounds.h"

const std::string FIGSounds::MUSIC_MENU = "sounds/fig_music_menu.ogg";
const std::string FIGSounds::MUSIC_INGAME = "sounds/fig_music_menu.ogg";	

FIGSounds::FIGSounds()   
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		m_PlayCounters[i] = 0;
	}
}

FIGSounds&	FIGSounds::Instance()
{
	static FIGSounds	Inst;
	return Inst;
}

void		FIGSounds::PlayMusic(const std::string& Name)
{
	AUDIO().PlayMusic(Name);
}

void		FIGSounds::PlaySoundSFX(SOUND_NAMES SFXEnum)
{
	if(SFXEnum == FIGSounds::EXPLOSION_VERYBIG)
	{
		int test = 0;
		test =1 ;
	}
	m_PlayCounters[(int)SFXEnum] = 0.001f;
	
}

void		FIGSounds::Tick(float dt)
{
	for(int i = 0; i < SOUND_NAMES_C; i++)
	{
		if( m_PlayCounters[i] > 0)
		{
			m_PlayCounters[i] -= dt;
			if(m_PlayCounters[i] <= 0)
			{
				InternalPlay((FIGSounds::SOUND_NAMES)i);
			}
		}
	}	
}



void		FIGSounds::InternalPlay(SOUND_NAMES SFXEnum)
{
	switch(SFXEnum)
	{
		case EXPLOSION_SMALL_1:
			AUDIO().PlayEvent("fig_explosion_small_1");
			break;

		case EXPLOSION_VERYBIG:
			AUDIO().PlayEvent("fig_explosion_verybig");			
		break;

		case ROCKET_IMPACT:
			AUDIO().PlayEvent("fig_rocket_impact");			
		break;

		case ROCKET_TRAVEL:
			AUDIO().PlayEvent("fig_rocket_travel");			
		break;
		
		case BULLETSOUND_ROCKET_TRAVEL:
			AUDIO().PlayEvent("fig_rocket_travel");			
		break;

		case BOSS_LASER_WARNING:
			AUDIO().PlayEvent("fig_boss_laser_warning");			
		break;

		case PICKUP_STAR:
			AUDIO().PlayEvent("fig_pickup_star");			
		break;

		case PICKUP_SHIELD:
			AUDIO().PlayEvent("fig_pickup_shield");	
		break;

		case PICKUP_HEALTH:
			AUDIO().PlayEvent("fig_life_restore");	
		break;

		case PICKUP_ORB:
			AUDIO().PlayEvent("fig_pickup_orb");	
		break;

		case SHIELD_OFF:
			AUDIO().PlayEvent("fig_shield_off");	
		break;

		case BULLETSOUND_NORMAL:
			AUDIO().PlayEvent("fig_bulletsound_normal");
		break;

		case BOSS_LASER:
			AUDIO().PlayEvent("fig_boss_laser");
		break;

		case BOSS_ARRIVE:
			AUDIO().PlayEvent("fig_boss_arrive");
		break;

		case BOSS_SHOOT:
			AUDIO().PlayEvent("fig_boss_shoot");
		break;

		case PLAYER_SPECIAL_APPEAR:
			AUDIO().PlayEvent("fig_player_special");
		break;
		

		//case BULLETSOUND_ROCKET:
		//	AUDIO().PlayEvent("fig_bulletsound_rocket");
		//break;

		//case BULLETSOUND_LASER:
		//	AUDIO().PlayEvent("fig_bulletsound_laser");
		//break;

		case PICKUP_SFX:
			AUDIO().PlayEvent("fig_pickup_sound");
		break;

		case TRANSOFORMING:
			AUDIO().PlayEvent("fig_transforming");
		break;

		default:
			break;

	}
}

